home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / UCRASM25.ARJ / PUTLSIZE.ASM < prev    next >
Assembly Source File  |  1991-10-12  |  2KB  |  104 lines

  1. StdGrp        group    stdlib,stddata
  2. stddata        segment    para public 'sldata'
  3. stddata        ends
  4. ;
  5. stdlib        segment    para public 'slcode'
  6.         assume    cs:stdgrp
  7.         extrn   sl_putc:far, sl_LSize:far, sl_ULSize:far
  8. ;
  9. ; Putl prints the value in DX:AX as a signed dword integer value.
  10. ;
  11.         public  sl_putlsize
  12. sl_Putlsize     proc    far
  13.         push    ax
  14.         push    bx
  15.         push    cx
  16.         push    dx
  17.         push    ax
  18.         call    sl_LSize
  19.         sub     cx, ax
  20.         js      NoSpcs
  21.         jcxz    NoSpcs
  22.         mov     al, ' '
  23. PutSpcs:        call    sl_Putc
  24.         loop    PutSpcs
  25. ;
  26. NoSpcs:         pop     ax
  27.         cmp     dx, 0
  28.         jge    Doit
  29.         push    ax
  30.         mov    al, '-'
  31.         call    sl_Putc
  32.         pop    ax
  33.         neg    dx
  34.         neg    ax
  35.         sbb    dx, 0
  36. ;
  37. DoIt:        call    puti2
  38.         pop    dx
  39.         pop    cx 
  40.         pop    bx 
  41.         pop    ax
  42.         ret
  43. sl_Putlsize     endp
  44. ;
  45. ; Putul prints the value in DX:AX as an unsigned dword integer value.
  46. ;
  47.         public    sl_PutULSize
  48. sl_PutULSize    proc    far
  49.         push    ax 
  50.         push    bx 
  51.         push    cx 
  52.         push    dx
  53.         push    ax
  54.         call    sl_ULSize
  55.         sub     cx, ax
  56.         js      NoSpcs2
  57.         jcxz    NoSpcs2
  58.         mov     al, ' '
  59. PutSpcs2:       call    sl_Putc
  60.         loop    PutSpcs2
  61. NoSpcs2:        pop     ax
  62. ;
  63.         call    PutI2
  64.         pop    dx 
  65.         pop    cx 
  66.         pop    bx 
  67.         pop    ax
  68.         ret
  69. sl_PutULSize    endp
  70. ;
  71. ; PutI2- Recursive routine to actually print the value in AX as an integer.
  72. ;
  73. Puti2        proc    near
  74.         call    Div10
  75.         cmp    ax, dx        ;See if dx:ax=0
  76.         jnz    NotDone
  77.         or    ax, ax
  78.         jz    Done
  79. NotDone:    push    bx
  80.         call    Puti2
  81.         pop    bx
  82. Done:        mov    al, bl
  83.         or    al, '0'
  84.         call    sl_Putc
  85.         ret
  86. PutI2        endp
  87. ;
  88. ; Div10- Divides DX:AX by 10 leaving the remainder in BL and the quotient
  89. ;     in DX:AX.
  90. ;
  91. Div10        proc    near
  92.         mov    cx, 10
  93.         mov    bx, ax
  94.         xchg    ax, dx
  95.         xor    dx, dx
  96.         div    cx
  97.         xchg    bx, ax
  98.         div    cx
  99.         xchg    dx, bx
  100.         ret
  101. Div10        endp
  102. stdlib        ends
  103.         end
  104.